<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/jquery-3.4.1.js"></script>
    <script src="js/axios.js"></script>
    <script>
        //登录操作
    async function login({ url, username, password }) {
      //axios的返回结果，本质是promise对象
      let { data: res } = await axios.get(url, { params: { username, password } })
      console.log(res.data)
      //保存登录返回读用户对象到本地存储
      sessionStorage.setItem('user', JSON.stringify(res.data))
      setTimeout(function() {
        location = 'goods-axios.html'
      }, 2000)
    }

    try {
      login({
        url: 'http://192.168.102.5:8888/api/private/v1/login',
        username: 'admin',
        password: '123456'
      })
    } catch (e) {
      console.log(e)
    }
    </script>
</head>
<body>
    <div id="app"></div>
</body>
</html>